﻿using System;
using System.Diagnostics;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input.Touch;
using GauntletFramework.Input;

namespace GauntletFramework.StateManagment.Menu
{
    public class MenuScrollBar : MenuItem
    {
        public float ScrollValue = 0;
        
        public MenuScrollBar(SpriteFont Font, string Text, Vector2 Center, float ScrollValue)
            : base(Font, Text, "", Center)
        {
            this.ScrollValue = ScrollValue;
        }
        /*
        public MenuScrollBar(SpriteFont Font, string Text, string Target, Vector2 Center, Color TextColor)
            : base(Font, Text, Target, Center, TextColor)
        {
        }

        public MenuScrollBar(SpriteFont Font, string Text, string Target, Color TextColor)
            : base(Font, Text, Target, TextColor)
        {
        }

        public MenuScrollBar(string Text, string Target, Color TextColor)
            : base(Text, Target, TextColor)
        {
        }

        public MenuScrollBar(string Text, string Target)
            : base(Text, Target)
        {
        }
        */
        public override void  Update(GameTime gameTime)
        {
            base.Update(gameTime);

            if (!selected)
                return;

            BasicInput bi = StaticGame.BasicInput;
            if (bi.ArrowLeft == AdvancedButtonState.Pressed)
                ScrollValue -= 0.1f;
            if (bi.ArrowRight == AdvancedButtonState.Pressed)
                ScrollValue += 0.1f;

            if (ScrollValue < 0f) ScrollValue = 0f;
            if (ScrollValue > 1f) ScrollValue = 1f;
        }

        public override void Draw(GameTime gameTime)
        {
            SpriteBatch sb = ((GNTMainGame)Game).SpriteBatch;
            Color CurrentColor = DarkTextColor;
            string Value = new string('-', (int)(ScrollValue * 10f));
            Value = Value.PadRight(10, ' ');
            string ValueText = Text + " ["+Value+"]";
            if (selected)
                CurrentColor = TextColor;

            sb.DrawString(Font, ValueText, Center, CurrentColor);
        }
    }
}
